<?php
/**
 * Description: 清洗数据（Brand_content）
 * Created by PhpStorm.
 * User: congyukun
 * Date: 2021/3/4
 * Time: 16:50
 */

use Biz\model\brand\BrandContentKeywords;

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';


$start = time();
$page = 1;
$pageSize = 1000;
$list = [];

do {
    $limit = [($page - 1) * $pageSize, $pageSize];
    //查询0点更新数据
    $auto_up_time = date("Y-m-d 00:00:00");
    
    $where = [
        'auto_up_time' => $auto_up_time,
        'status' => BrandContentKeywords::STATUS_NORMAL_ON,
        'LIMIT' => $limit,
    ];
    
    $list = BrandContentKeywords::select(['id', 'new_keywords'], $where);
    if ($list) {
        foreach ($list as $row) {
            $up_where['id'] = $row['id'];
            $data['search_keywords'] = $row['new_keywords'];
            $data['new_keywords'] = '';
            $data['update_time'] = date("Y-m-d H:i:s");
            BrandContentKeywords::update($data, $up_where)->rowCount();
        }
    }
    $page++;
} while ($list);
$end = time();
var_dump(date('Y-m-d-H-i-s') . '清洗数据完成,总耗时:' . ($end - $start) . '秒，' . (($end - $start) / 60) . '分');
